<%@page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%response.setCharacterEncoding("GBK");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>价值投机内容编辑</title>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" charset="UTF-8" language="javascript"  src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/dtree.js"></script>
<link rel="stylesheet" type="text/css" href="../css/dtree.css" />
<script type="text/javascript" language="javascript" src="../js/common.js"></script>
<link rel="stylesheet" href="../themes/default/default.css" />
<link rel="stylesheet" href="../plugins/code/prettify.css" />
<script charset="utf-8" src="../kindeditor.js?v=20150402"></script>
<script charset="utf-8" src="../lang/zh_CN.js?v=20150402"></script>
<script charset="utf-8" src="../plugins/code/prettify.js?v=20150402"></script>

</head>
<script type="text/javascript" language="javascript">
	//JSP
	KindEditor.ready(function(K) {
		var editor1 = K.create('textarea[name="content"]', {
			cssPath : '../plugins/code/prettify.css',
			uploadJson : '../jsp/upload_json.jsp',
			fileManagerJson : '../jsp/file_manager_json.jsp',
			allowFileManager : true,
			filterMode: false,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					document.forms['example'].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					document.forms['example'].submit();
				});
			}
		});
		prettyPrint();
	});
	var headOptions = "", indexOptions = "", newstockOptions = "";
	var titleLen = 40;

	function checkWord() {
		var content = getEditorHTMLContents();
		var wordlength = content.length;
		$("#wordlength").html(wordlength);
		if (wordlength > 0) {
			return true;
		} else {
			alert("请输入内容");
			return false;
		}
	};

	function checkTitleLength(val) {
		$("#titleInsert").html(val.length);
	};

	function check() {
		if (!checkWord()) {
			return false;
		}

		if (document.form1.right == "-1" || document.form1.right == -1) {
			alert("请选择阅读权限");
			return false;
		}
		if (document.form1.title.value == "") {
			document.getElementById("title_tip").innerHTML = "<font color=red>请输入标题</font>";
			document.form1.title.focus();
			alert("请输入标题");
			return false;
		} else if (document.form1.title.value.length > titleLen) {
			document.getElementById("title_tip").innerHTML = "<font color=red>标题过长</font>";
			document.form1.title.focus();
			alert("标题过长，请检查");
			return false;
		} else {
			document.getElementById("title_tip").innerHTML = "";
		}
		if (document.form1.showtime.value == "") {
			document.getElementById("showtime_tip").innerHTML = "<font color=red>请输入日期</font>";
			document.form1.showtime.focus();
			alert("请输入显示日期");
			return false;
		} else
			document.getElementById("showtime_tip").innerHTML = "";
		if ($("#ext_CheckBox").checked) {
			if (document.form1.exttime.value == "") {
				document.getElementById("exttime_tip").innerHTML = "<font color=red>请输入日期</font>";
				document.form1.exttime.focus();
				alert("请输入过期日期或取消自定义");
				return false;
			} else
				document.getElementById("exttime_tip").innerHTML = "";
		}
		return true;
	}

	// 获取编辑器中HTML内容
	function getEditorHTMLContents() {
		// 取得HTML内容
		html = editor.html();

		// 同步数据后可以直接取得textarea的value
		editor.sync();
		/*   html = document.getElementById('editor_id').value; // 原生API
		  html = K('#editor_id').val(); // KindEditor Node API
		  html = $('#editor_id').val(); // jQuery */
		return html;
	}
	//设置编辑器中内容
	function SetEditorContents(ContentStr) {
		// 设置HTML内容
		editor.html(ContentStr);
	}
</script>
<body>

	<div id="warp" style="width: 100%;">
		<form method="post" action="../JspsmartUploadServlet" name="form1"
			ENCTYPE="multipart/form-data" oncheck="return check()">
			<table width="100%" cellpadding="0" cellspacing="15">
				<tr>
					<td align="right">标题：</td>
					<td align="left"><input class="input" style="width: 340px;"
						type="text" name="title" onkeyup="checkTitleLength(this.value)" />
						<span><font color="red">*必填</font></span> <br /> <span><font
							color="blue">限制输入：<span id="titleLen">0</span>，当前字数：<span
								id="titleInsert">0</span>
						</font></span></td>
					<td align="left" id="title_tip" width="80px;">&nbsp;</td>
				</tr>
				<tr>
					<td align="right">封面图片：</td>
					<td align="left"><input class="input" type="file" name="img" />
						<span><font color="red">*图片名不可为中文,当天图片不能重名.<br />*格式为：jpg,png,gif,bmp.大小1M以内，（大图片建议尺寸：900像素 * 500像素）
						</font> </span></td>
				</tr>
				<tr>
					<td align="right">文章阅读权限：</td>
					<td align="left"><select name="right">
							<option selected="selected" value="0">公开</option>
							<!-- <option value="0"></option> -->
							<option value="1">仅会员可读</option>
					</select> <span style="display: inline"><font color="red">*选择素材的阅读权限.</font>
					</span></td>
				</tr>
				<tr>
					<td align="right">文章菜单：</td>
					<td align="left"><select name="menu">
							<option value="-1">选择文章所属菜单</option>
							<option value="11">资金流动论</option>
							<option value="21">独家案例</option>
							<option selected="selected" value="22">独家观点</option>
							<option value="33">会员案例</option>
					</select> <span style="display: inline"><font color="red">*选择素材的归属菜单.</font>
					</span></td>
				</tr>
				<tr>
					<td align="right">股票代码：</td>
					<td align="left" colspan="2"><input class="input" type="text"
						name="stockcode" /></td>
				</tr>
				<tr>
					<td align="right">股票名称：</td>
					<td align="left" colspan="2"><input class="input" type="text"
						name="stockname" /></td>
				</tr>
				<tr>
					<td align="right">作 者：</td>
					<td align="left" colspan="2"><input class="input" type="text"
						name="author" value="裴明涛" readonly="readonly" /></td>
				</tr>
				<tr>
					<td align="right">来 源：</td>
					<td align="left" colspan="2"><input class="input" type="text"
						name="source" value="原创" readonly="readonly" /></td>
				</tr>

				<tr>
					<td align="right" valign="top">文章内容：</td>
					<td align="left" colspan="2"><textarea id="editor_id"
							name="content" style="width: 700px; height: 300px;">
						&lt;strong&gt;HTML内容&lt;/strong&gt;
						</textarea></td>
				</tr>
				<tr>
					<td align="left">&nbsp;</td>
					<td align="left" colspan="2"><input type="submit" value="发　　布"
						class="btn_input" onClick="return check()" /></td>
				</tr>
			</table>
		</form>
	</div>
	<br />
	<!-- <a href="downLoadFileList.jsp">下载</a> -->
</body>
</html>
